﻿<%@ Control Language="VB" Inherits="System.Web.Mvc.ViewUserControl" %>
<%@ Import Namespace="Equipment.DataAccess" %>
<table>
    <tr>
        <td>
            <input type="submit" class="button" value="Add Measure" onclick="addMeasure(); return false;" />
            <%= Html.Hidden("maxId", If(ViewData("MaxID"),0))%>
        </td>
    </tr>
    <tr>
        <td>
            <table id="measureTable" class="data-table">
                <thead>
                    <tr>
                        <th>
                            &nbsp;
                        </th>
                        <th>
                            Measure Name
                        </th>
                        <th>
                            Type
                        </th>
                        <th>
                            Value
                        </th>
                        <th>
                            Optimal Value\Range
                        </th>
                        <th>
                            Comments
                        </th>
                    </tr>
                </thead>
                <tbody>
                    <% Dim i As Integer = 1%>
                    <% For Each measure In ViewData("MeasureList")%>
                    <tr id="meas_<%: i%>">
                        <td>
                            <input type="image" src="../../content/img/delete.png" onclick="deleteWithEffect(<%: i%>); return false;"
                                alt="Delete" />
                        </td>
                        <td>
                            <%: measure.MeasureDescription%>
                            <%= Html.Hidden(String.Format("measureID_{0}", i), measure.ID)%>
                            <%= Html.Hidden(String.Format("measureName_{0}", i), measure.MeasureDescription)%>
                            <%= Html.Hidden(String.Format("measureType_{0}", i), measure.MeasureType)%>
                            <%= Html.Hidden(String.Format("measureLookupValue_{0}", i), measure.LookupValue)%>
                            <%= Html.Hidden(String.Format("measureOptimalLookupValue_{0}", i), measure.OptimalLookupValue)%>
                            <%If measure.MeasureType = MeasureType.Integer Then%>
                            <%= Html.Hidden(String.Format("measureOptimalMin_{0}", i), measure.IntegerMin)%>
                            <%= Html.Hidden(String.Format("measureOptimalMax_{0}", i), measure.IntegerMax)%>
                            <%Else%>
                            <%= Html.Hidden(String.Format("measureOptimalMin_{0}", i), measure.DecimalMin)%>
                            <%= Html.Hidden(String.Format("measureOptimalMax_{0}", i), measure.DecimalMax)%>
                            <%End If%>
                        </td>
                        <td>
                            <%: CType(measure.MeasureType, MeasureType).ToString()%>
                        </td>
                        <td>
                            <%: measure.LookupValue%>
                        </td>
                        <td>
                            <% Dim type As MeasureType = CType(measure.MeasureType, MeasureType)%>
                            <% If type = MeasureType.Integer Or type = MeasureType.Decimal Then%>
                            <%: measure.IntegerMin%><%: measure.DecimalMin%>
                            /
                            <%: measure.IntegerMax%><%: measure.DecimalMax%>
                            <% Else%>
                            <%: measure.OptimalLookupValue%>
                            <% End If%>
                        </td>
                        <td>
                            <%= Html.Hidden(String.Format("measureRequiredComments_{0}", i), measure.RequiredComments)%>
                            <% If measure.RequiredComments > 0 Then%>
                                <img src ="../../../Content/img/active.gif" alt = "Enabled" />
                            <% Else%>
                                <img src ="../../../Content/img/remove.png" alt = "Disabled" />
                            <% End If%>
                        </td>
                    </tr>
                    <% i = i + 1%>
                    <% Next%>
                </tbody>
            </table>
        </td>
    </tr>
</table>
